package com.boolib.animate.framework.web;

import com.alibaba.fastjson.JSON;
import com.boolib.animate.framework.entity.AnimateUser;
import com.boolib.animate.framework.entity.bo.UserBo;
import com.boolib.animate.framework.entity.bo.UserRegisterBo;
import com.boolib.animate.framework.service.advice.AnimateUserService;
import com.boolib.animate.framework.service.base.impl.BaseAnimateUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;

/**
 * @author nier
 * @create 2020-03-02 17:42
 */

@RequestMapping("/api/user")
@RestController
public class AnimateUserController {


    @Autowired
    private HttpSession httpSession;
    @Autowired
    private AnimateUserService animateUserService;

    @PostMapping("login")
    public AnimateUser login(@RequestBody UserBo userBo){
        final AnimateUser login = animateUserService.login(userBo);
        httpSession.setAttribute("current",login);
        return login;
    }

    @ResponseStatus(HttpStatus.NO_CONTENT)
    @PostMapping("register")
    public  void register(@RequestBody UserRegisterBo userRegisterBo){
        final AnimateUser register = animateUserService.register(userRegisterBo);
    }


}
